package com.xone.xapp;

import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;

public class Main extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);// 取消标题
		setContentView(R.layout.main);
		Button b1 = (Button) findViewById(R.id.button1);
		b1.setText("登录");
		b1.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				new AsyncTask<String, Void, String>() {
					@Override
					protected String doInBackground(String... params) {
						if (isCancelled()) {
							return null;
						}
						if (null == params || params.length == 0) {
							return null;
						}
						return HttpUtils.getIdCode(params[0]);
					}
					@Override
					protected void onPostExecute(String result) {
						super.onPostExecute(result);
						if (null != result) {
							new AutoLoginDataTask(getBaseContext()).execute("test-admin", "111111", result);
						}
					}
				}.execute(Constants.APP_URL + "/login/main.html");
			}
		});

		Button b2 = (Button) findViewById(R.id.button2);
		b2.setText("Grid");
		b2.setOnClickListener(new OnClickListener() {

			public void onClick(View v) {
				Intent i = new Intent(Main.this,
						GuideActivity.class);
				startActivity(i);
			}
		});
		
		Button b3 = (Button) findViewById(R.id.button3);
		b3.setText("登录界面");
		b3.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				Intent i = new Intent(Main.this, LoginActivity.class);
				startActivity(i);
			}
		});
		
		Button b4 = (Button) findViewById(R.id.button4);
		b4.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				Intent i = new Intent(Main.this, ProductListActivity.class);
				startActivity(i);
			}
		});
	}
}
